plat: rcar: Generate platform compatible string
authorMarek Vasut <[email protected]>
Thu, 11 Oct 2018 14:15:41 +0000 (16:15 +0200)
committerMarek Vasut <[email protected]>
Thu, 6 Dec 2018 09:23:54 +0000 (10:23 +0100)
Generate /compatible string for the platform, so that the subsequent
stages know which platform they are running on. This could be useful
when ie. building U-Boot that contains DTs for multiple platforms and
can thus decide on which platform it is running. This would ultimately
allow single bootloader binary for all Gen3 platforms.

Signed-off-by: Marek Vasut <[email protected]>
plat/renesas/rcar/bl2_plat_setup.c

index dce8c5a5abb5344c1164fcbe58ce508762f258c9..754bbdffcfdbbb10d5c5431593bb7253fe21e140 100644 (file)
@@ -328,6 +328,76 @@ meminfo_t *bl2_plat_sec_mem_layout(void)
        return &bl2_tzram_layout;
 }
 
+static void bl2_populate_compatible_string(void *fdt)
+{
+       uint32_t board_type;
+       uint32_t board_rev;
+       uint32_t reg;
+       int ret;
+
+       /* Populate compatible string */
+       rcar_get_board_type(&board_type, &board_rev);
+       switch (board_type) {
+       case BOARD_SALVATOR_X:
+               ret = fdt_setprop_string(fdt, 0, "compatible",
+                                        "renesas,salvator-x");
+               break;
+       case BOARD_SALVATOR_XS:
+               ret = fdt_setprop_string(fdt, 0, "compatible",
+                                        "renesas,salvator-xs");
+               break;
+       case BOARD_STARTER_KIT:
+               ret = fdt_setprop_string(fdt, 0, "compatible",
+                                        "renesas,m3ulcb");
+               break;
+       case BOARD_STARTER_KIT_PRE:
+               ret = fdt_setprop_string(fdt, 0, "compatible",
+                                        "renesas,h3ulcb");
+               break;
+       case BOARD_EBISU:
+       case BOARD_EBISU_4D:
+               ret = fdt_setprop_string(fdt, 0, "compatible",
+                                        "renesas,ebisu");
+               break;
+       default:
+               NOTICE("BL2: Cannot set compatible string, board unsupported\n");
+               panic();
+       }
+
+       if (ret < 0) {
+               NOTICE("BL2: Cannot set compatible string (ret=%i)\n", ret);
+               panic();
+       }
+
+       reg = mmio_read_32(RCAR_PRR);
+       switch (reg & RCAR_PRODUCT_MASK) {
+       case RCAR_PRODUCT_H3:
+               ret = fdt_appendprop_string(fdt, 0, "compatible",
+                                           "renesas,r8a7795");
+               break;
+       case RCAR_PRODUCT_M3:
+               ret = fdt_appendprop_string(fdt, 0, "compatible",
+                                           "renesas,r8a7796");
+               break;
+       case RCAR_PRODUCT_M3N:
+               ret = fdt_appendprop_string(fdt, 0, "compatible",
+                                           "renesas,r8a77965");
+               break;
+       case RCAR_PRODUCT_E3:
+               ret = fdt_appendprop_string(fdt, 0, "compatible",
+                                           "renesas,r8a77990");
+               break;
+       default:
+               NOTICE("BL2: Cannot set compatible string, SoC unsupported\n");
+               panic();
+       }
+
+       if (ret < 0) {
+               NOTICE("BL2: Cannot set compatible string (ret=%i)\n", ret);
+               panic();
+       }
+}
+
 static void bl2_advertise_dram_entries(uint64_t dram_config[8])
 {
        char nodename[32] = { 0 };
@@ -676,6 +746,9 @@ lcm_state:
                panic();
        }
 
+       /* Add platform compatible string */
+       bl2_populate_compatible_string(fdt);
+
        /* Print DRAM layout */
        bl2_advertise_dram_size(product);